<template>
  <div style="height: 100vh; background: #e8e8e8; padding: 10px">
    <van-nav-bar title="请选择问题类型" left-arrow @click-left="onClickLeft" style="background: #e8e8e8" />
    <div style="margin-top: 10px">
      <div
        v-for="item in problemTypeList"
        :key="item.code"
        @click="toDetails(item)"
        style="background-color: #fff; border-radius: 7px; margin-bottom: 10px; text-align: center; padding: 20px; font-size: 16px; color: #323233"
      >
        {{ item.name }}
      </div>
    </div>
  </div>
</template>

<script>
import { getDictChildList } from '@api/rd/index'
import { Notify } from 'vant'

export default {
  components: {},
  data() {
    return {
      problemTypeList: [],
      billNo: ''
    }
  },
  mounted() {
    this.getDictChildList('PROBLEM_TYPE', 'problemTypeList')
  },
  created() {
    this.billNo = this.$route.query.billNo
  },
  methods: {
    onClickLeft() {
      history.back()
    },
    toDetails(item) {
      this.$router.push({ path:'sealIssuesDetail', query:{ billNo: this.billNo, problemType: item.name } })
    },
    async getDictChildList(name, list) {
      if (!this[list].length) {
        const params = {
          name: name
        }
        try {
          const res = await getDictChildList('dict', params)
          if (res.code == 200) {
            this[list] = res.data
          } else {
            if (res.msg) {
              Notify({ type: 'warning', message: res.msg })
            } else {
              Notify({ type: 'warning', message: '获取问题类型失败!' })
            }
          }
        } catch (error) {
          Notify({ type: 'warning', message: '获取问题类型异常!' })
        }
      }
    }
  }
}
</script>
